import 'dart:convert';
import 'dart:ffi';

List<Menu> menuFromJson(String str) => List<Menu>.from(json.decode(str).map((x) => Menu.fromJson(x)));

String menuToJson(List<Menu> data) => json.encode(List<dynamic>.from(data.map((x) => x.toJson())));

class Menu {
  String functionName;
  int functionType;
  List<Child> children;

  Menu({
    required this.functionName,
    required this.functionType,
    required this.children,
  });

  factory Menu.fromJson(Map<String, dynamic> json) => Menu(
    functionName: json["functionName"],
    functionType: json["functionType"],
    children: List<Child>.from(json["children"].map((x) => Child.fromJson(x))),
  );

  Map<String, dynamic> toJson() => {
    "functionName": functionName,
    "functionType": functionType,
    "children": List<dynamic>.from(children.map((x) => x.toJson())),
  };
}

class Child {
  String functionName;
  String source;
  String path;
  int functionType;

  Child({
    required this.functionName,
    required this.source,
    required this.path,
    required this.functionType,
  });

  factory Child.fromJson(Map<String, dynamic> json) => Child(
    functionName: json["functionName"],
    source: json["source"],
    path: json["path"],
    functionType: json["functionType"],
  );

  Map<String, dynamic> toJson() => {
    "functionName": functionName,
    "source": source,
    "path": path,
    "functionType": functionType,
  };
}
